package com.quiz.bis.controller;

import com.quiz.bis.domain.bo.MemberApproveBo;
import com.quiz.bis.domain.bo.MemberInviteBo;
import com.quiz.bis.domain.vo.ExamMemberVo;
import com.quiz.bis.domain.vo.PendingMemberVo;
import com.quiz.bis.service.IExamGroupMemberService;
import com.quiz.common.core.domain.R;
import com.quiz.common.mybatis.core.page.PageQuery;
import com.quiz.common.mybatis.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 考试组成员管理
 */
@RestController
@RequestMapping("/exam/group/member")
@Tag(name = "考试组成员管理")
@RequiredArgsConstructor
public class ExamGroupMemberController {
    private final IExamGroupMemberService memberService;

    /**
     * 获取待审核成员列表
     *
     * @param groupId
     * @return
     */
    @GetMapping("/pending")
    public TableDataInfo<PendingMemberVo> getPendingMembers(Long groupId, PageQuery pageQuery) {
        return memberService.getPendingMembers(groupId, pageQuery);
    }

    /**
     * 获取待审核成员列表
     *
     * @param groupId
     * @return
     */
    @GetMapping("/stu")
    public TableDataInfo<ExamMemberVo> getStuMembers(Long groupId, PageQuery pageQuery, String keyword) {
        return memberService.getStuMembers(groupId, keyword, pageQuery);
    }

    /**
     * 审核成员申请
     *
     * @param bo
     * @return
     */
    @PostMapping("/approve")
    public R<Void> approveMember(@Valid @RequestBody MemberApproveBo bo) {
        return memberService.approveMember(bo);
    }

    /**
     * 邀请成员
     *
     * @param bo
     * @return
     */
    @PostMapping("/invite")
    public R<Void> inviteMember(@Valid @RequestBody MemberInviteBo bo) {
        return memberService.inviteMember(bo);
    }

    /**
     * 移除成员
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R<Void> removeMember(@PathVariable Long id) {
        return memberService.removeMember(id);
    }
}